
Ext.Loader.setConfig({
    enabled: true
});

Ext.Loader.setPath('Ext.ux', './extjs/ux');
Ext.require([
    'Ext.form.Panel',
    'Ext.ux.form.MultiSelect',
    'Ext.ux.form.ItemSelector'
]);

Ext.application({

	
   controllers: [
	'WindowsLogin',
	'MainMenu',
	'WindowsNewSpot',
	'ManagerSpot',
        'WindowsNewTrip',
        'ManagerTrip',
        'WindowsNewApp',
        'ManagerApp',
        'ManagerUser'
   ],
	  
	  
    models: [
        'User',
        'App',
        'Spot',
        'SpotDescription',
        'Trip',
        'TripDescription',
        'TripSpot',
        'AppTrip'

    ],

    stores: [
        'Users'
    ],

    name: 'Holo',

	
    launch: function() {
        //Ext.Ajax.on('beforerequest', function(conn, options) {
        //    console.log('beforerequest');
        //} );
        //
        //Ext.Ajax.on('requestcomplete', function(conn, response, options) {
        //    console.log('requestcomplete');
        //} );
        //
        //Ext.Ajax.on('requestexception', function(conn, response, options) {
        //    console.log('requestexception');
        //} );
        

      
	  // user connect ? 
     if(Ext.data.StoreManager.lookup('Users').count()==0){
            //console.log('reset all store and call the loggin windows');
            var win = Ext.create('Holo.view.user.WindowsLogin', {
                                   renderTo: Ext.getBody()
                             });
	
	      win.show();
	  }

	  
	
    },
    
    
    
    launchA : function(){
      Ext.create('Ext.tab.Panel', {
    //extend: 'Ext.tab.Panel',
    renderTo: Ext.getBody(),
    height: 489,
    width: 731,
    activeTab: 0,
            items: [
                {
                    xtype: 'panel',
                    padding: 20,
                    height: 100,
                    title: 'Tab 1',
                    items: [
                        {
                            xtype: 'panel',
                            height: 100,
                            width: '99,9%',
                            margin: 5,
                            
                            autoScroll: true,
                            collapsible: true,
                            title: 'My Panel',
                            items: [
                                {
                                    xtype: 'panel',
                                    minheight: 40,
                                }
                            ]
                        },
                        {
                            xtype: 'panel',
                            margin: 5,
                            height: 100,
                            autoScroll: true,
                            collapsible: true,
                            title: 'My Panel'
                        }
                    ]
                },
                {
                    xtype: 'panel',
                    title: 'Tab 2'
                },
                {
                    xtype: 'panel',
                    title: 'Tab 3'
                }
            ]

});  
    },
    
    launchB : function(){
        
Ext.create('Ext.form.Panel', {
    title: 'Upload a Photo',
    width: 400,
    bodyPadding: 10,
    frame: true,
    renderTo: Ext.getBody(),
    items:[{
        xtype: 'filefield',
        name: 'image_field',
        fieldLabel: 'Photo',
        labelWidth: 50,
        msgTarget: 'side',
        allowBlank: false,
        anchor: '100%',
        buttonText: 'Select Photo...'
    }],

    buttons: [{
        text: 'Upload',
        handler: function() {
            var form = this.up('form').getForm();
            if(form.isValid()){
                form.submit({
                    url: 'database/processFile.php',
                    waitMsg: 'Uploading your photo...',
                    success: function(fp, o) {
			console.log(o.result);
                        Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
                    },
		     failure: function(form, action) {
			console.log(action);
			switch (action.failureType) {
			    case Ext.form.action.Action.CLIENT_INVALID:
				Ext.Msg.alert('Failure', 'Form fields may not be submitted with invalid values');
				break;
			    case Ext.form.action.Action.CONNECT_FAILURE:
				Ext.Msg.alert('Failure', 'Ajax communication failed');
				break;
			    case Ext.form.action.Action.SERVER_INVALID:
			       Ext.Msg.alert('Failure', action.result.msg);
		       }
		    }
                });
            }
        }
    }]
});


 } 
    
});
